package uk.co.q3c.deplan.google;

import javax.persistence.Id;

import uk.co.q3c.deplan.client.util.Q3StringUtil;
import uk.co.q3c.deplan.client.util.apache.StringUtils;

import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Unindexed;

@Unindexed
@Cached(expirationSeconds = 600)
public class TreeSetEntry implements Comparable<TreeSetEntry> {
	@Id
	private Long id;
	private String Q3DateUtil;

	/**
	 * 
	 */
	protected TreeSetEntry() {
		super();
	}

	protected TreeSetEntry(String Q3DateUtil) {
		super();
		this.Q3DateUtil = Q3DateUtil;
	}

	@Override
	public int compareTo(TreeSetEntry other) {
		if (!(other instanceof TreeSetEntry)) {
			throw new RuntimeException("not comparable");
		}
		return Q3StringUtil.compare(Q3DateUtil, other.getQ3DateUtil());
	}

	@Override
	public boolean equals(Object other) {
		if (other == null) {
			return false;
		}
		if (!(other instanceof TreeSetEntry)) {
			return false;
		}
		TreeSetEntry tse = (TreeSetEntry) other;

		return StringUtils.equals(Q3DateUtil, tse.getQ3DateUtil());
	}

	public String getQ3DateUtil() {
		return Q3DateUtil;
	}

	public void setQ3DateUtil(String Q3DateUtil) {
		this.Q3DateUtil = Q3DateUtil;
	}

	public Long getId() {
		return id;
	}
}
